package cn.tpshion.devops.node;

import cn.tpshion.devops.common.enums.NodeType;
import cn.tpshion.devops.domain.entity.NodeData;
import cn.tpshion.devops.node.data.K8sData;
import cn.tpshion.devops.node.support.NodeContext;
import com.alibaba.fastjson2.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class K8sNode extends Node<K8sData>{

    @Override
    public NodeType nodeType() {
        return NodeType.K8S;
    }

    @Override
    public void handle(NodeContext nodeContext) throws Exception {
        log.info("K8sNode nodeContext:{}", nodeContext);
        K8sData data = getData(nodeContext);

    }

    @Override
    protected K8sData getData(NodeContext nodeContext) {
        NodeData nodeData = nodeContext.getNodeData();
        K8sData data = JSON.parseObject(JSON.toJSONString(nodeData.getData()), K8sData.class);
        return data;
    }
}
